<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">

<head>
    <meta charset="UTF-8">
    <title>商品类型列表</title>
    <link rel="stylesheet" th:href="@{/css/bootstrap.min.css}" />
    <script th:src="@{/js/jquery-3.6.0.min.js}"></script>
    <script type="text/javascript">
        function deleteGoodsType(element) {
            const tcode = element.getAttribute('data-tcode');
            const tname = element.getAttribute('data-tname');

            if (confirm("确定要删除 " + tname + " 的记录吗？")) {
                window.location.href = '/shopping/goodsType/delete?tcode=' + tcode;
            }
        }
    </script>
</head>

<body>
    <div class="panel panel-primary">
        <div class="panel-heading">
            <div th:replace="~{header}">
            </div>
        </div>
    </div>
    <br><br>
    <div class="container">
        <div class="panel panel-primary">
            <div class="panel-heading">
                <h3 class="panel-title">商品类型列表</h3>
            </div>

            <div class="panel-body">

                <div>
                    <button onclick="location.href='/shopping/goodsType/add';return false;">增加商品类型</button>
                    <br><br>
                </div>
                <div class="table table-responsive">
                    <table id="tb" class="table table-bordered table-hover">
                        <tbody class="text-center">
                            <tr>
                                <th>序号</th>
                                <th>类型编号</th>
                                <th>类型名称</th>
                                <th>删除</th>
                            </tr>
                            <tr th:each="goodstype,status:${allGoodsType}">

                                <td><span th:text="${status.count}"></span></td>
                                <td>
                                    <a th:href="@{/goodsType/edit(tcode=${goodstype.tcode})}"
                                        th:text="${goodstype.tcode}"></a>
                                </td>
                                <td>
                                    <a th:href="@{/goodsType/edit(tcode=${goodstype.tcode})}"
                                        th:text="${goodstype.tname}"></a>
                                </td>
                                <td>
                                    <a href="#" th:attr="data-tcode=${goodstype.tcode}, data-tname=${goodstype.tname}"
                                        onclick="deleteGoodsType(this)">删除</a>
                                </td>

                            </tr>
                        </tbody>
                    </table>
                </div>

            </div>
        </div>
    </div>
</body>

</html>